package com.zhanggm.springcloud.consul.controller;

import com.zhanggm.springcloud.consul.config.ConsulConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Scope;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RefreshScope
@RestController
@Scope("prototype")
public class TestController {

    @Autowired
    private RestTemplate restTemplate;

    public TestController() {
        System.out.println("TestController init");
    }

    @Autowired
    private ConsulConfig consulConfig;

    @Value("${config.info}")
    private String configInfo;

    @RequestMapping("test")
    public Object test(){
        /*ResponseEntity<ConsulConfig> url = restTemplate.getForEntity("url", ConsulConfig.class);*/
        System.out.println(configInfo);
        return consulConfig;
    }
}
